/*
This file is part of vlc-remote.

vlc-remote is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

vlc-remote is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with vlc-remote.  If not, see <http://www.gnu.org/licenses/>.
*/
Qt.include("mediaRemoteFunctions.js");
//Qt.include("remoteStatus.js");

function RemoteControl() {
    this._init();
}

RemoteControl.prototype = {
    /* private methods */
    _init: function() {
        console.log("RemoteControl init");
        //this._currentStatus = new RemoteStatus();
    },
    _currentTrackUID:"",
    /* protected methods */
    _updateStatus: function(remoteStatus) {
        //console.log(_unescape(remoteStatus.title));
        appWindow.title = _unescape(remoteStatus.title);
        appWindow.album = _unescape(remoteStatus.album);
        appWindow.artist = _unescape(remoteStatus.artist);
        //sliderVolume.value = remoteStatus.volume;
        //sliderPosition.value = remoteStatus.percentagePlayed;
        appWindow.volume = remoteStatus.volume;
        appWindow.played = remoteStatus.percentagePlayed;
        appWindow.position = _formatTime(remoteStatus.position);
        appWindow.duration = _formatTime(remoteStatus.duration);
        // should update playing / paused state and swap graphics as appropriate
        appWindow.playing = (1 == remoteStatus.state || 2 == remoteStatus.state || 4 == remoteStatus.state);
        appWindow.paused = (2 == remoteStatus.state);
        // update shuffle and repeat
        appWindow.shuffle = (remoteStatus.shuffle == ShuffleMode.SHUFFLE);
        appWindow.repeat = (remoteStatus.repeat == RepeatMode.ALL);
        // change art if appropraite
        if (this._currentTrackUID != remoteStatus.uid) {
            try {
                if (coverArtModel && coverArtModel.reload) coverArtModel.reload();
                this._currentTrackUID = remoteStatus.uid;
            }
            catch (e) {
            }
        }
        //this._currentTrackUID = remoteStatus.uid;
        //this._currentStatus = remoteStatus;
    },
    /* public interface methods */


    ping: function() { return false; },
    getStatus: function() {},
    getPlaylist: function() {},
    requestTrackById: function(trackId) {},
    requestTrackByPath: function(path) {},
    requestTrackNext: function() {},
    requestTrackPrevious: function() {},
    requestStartPlayback: function() {},
    requestResumePlayback: function() {},
    requestStopPlayback: function() {},
    requestPausePlayback: function() {},
    requestToggleFullscreen: function() {},
    requestSetVolume: function(volume) {},
    requestIncreaseVolume: function(increment) {},
    requestDecreaseVolume: function(increment) {},
    requestToggleMute: function() {},
    requestShuffleMode: function(mode) {},
    requestLoopMode: function(mode) {},
    requestSeekToPercentage: function(percentage) {},
    requestPlaylist: function() {},
    requestBrowse: function() {},
    getIpAddress: function() {},
    requestQueueByPath: function(path) {},
    requestClearPlaylist: function() {},
    requestDeleteFromPlaylist: function(id) {}
}
